﻿using System;
using System.Collections.Generic;
using System.Data.Entity.ModelConfiguration;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace MN.Framework.Common.Security
{
    public class UsersInRoleMap : EntityTypeConfiguration<UsersInRole>
    {
        public UsersInRoleMap()
        {
            // Primary Key
            this.HasKey(t => t.ID);

            // Properties
            // Table & Column Mappings
            this.ToTable("UsersInRoles");
            this.Property(t => t.UserID).HasColumnName("UserRef");
            this.Property(t => t.RoleID).HasColumnName("RoleRef");
            this.Property(t => t.ID).HasColumnName("UserRoleID");

            // Relationships
            this.HasRequired(t => t.Role)
                .WithMany(t => t.UsersInRoles)
                .HasForeignKey(d => d.RoleID);
            this.HasRequired(t => t.User)
                .WithMany(t => t.UsersInRoles)
                .HasForeignKey(d => d.UserID);

        }
    }
}
